package com.dwxt.parabolic.controller;

import com.dwxt.common.base.BaseResult;
import com.dwxt.common.base.Page;
import com.dwxt.parabolic.entity.Event;
import com.dwxt.parabolic.service.EventService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RequestMapping("/parabolic/event")
@RestController
public class EventController {
    @Autowired
    private EventService eventService;

    /**
     * 事件分页查询
     */
    @RequestMapping("/list")
    public BaseResult getEventList(Page page, Event event,String parentId) {
        return eventService.getEventList(page,event,parentId);
    }
    /**
     * 事件详情查询
     */
    @CrossOrigin
    @RequestMapping("/selectById")
    public BaseResult selectById(String id) {
        return eventService.selectById(id);
    }

    @RequestMapping("/update")
    public BaseResult update(Event event){
        return eventService.update(event);
    }

    /**
     * 下载压缩包
     * @param id
     * @return
     */
    @RequestMapping("/load")
    public BaseResult load(String id) throws IOException {
        return eventService.load(id);
    }

    /**********************************超脑调用接口**********************************************/
    /**
     * 超脑插入事件
     */
    // TODO
    @RequestMapping("/add")
    public BaseResult add(Event event){
        return eventService.add(event);
    }

}
